package com.power.using.sharlockchat.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.power.using.sharlockchat.R;
import com.power.using.sharlockchat.base.BaseMainFragment;
import com.power.using.sharlockchat.eventbus.EventCenter;
import com.power.using.sharlockchat.interfaces.Constant;
import com.power.using.sharlockchat.interfaces.DialogClick;
import com.power.using.sharlockchat.utils.GlideCacheUtil;
import com.power.using.sharlockchat.utils.LogUtils;
import com.power.using.sharlockchat.utils.SPUtil;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by 聪明一只哈 on 2018/5/25.
 * Time: 2018/5/25  10:35
 */

public class SelfInfoFrament extends BaseMainFragment {


    @BindView(R.id.toolbar_title)
    TextView toolbarTitle;

    @BindView(R.id.personal_btn_quit)
    Button personalBtnQuit;
    Unbinder unbinder;
  //  private Banner homeMZBanner;
    private RecyclerView homeRV;
    private TextView toolTitle;
    private ImageView mMenu;



    public static SelfInfoFrament newInstance() {

        Bundle args = new Bundle();

        SelfInfoFrament fragment = new SelfInfoFrament();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_four, container, false);
        unbinder = ButterKnife.bind(this, view);
        initView(view);
        return view;
    }

    private void initView(View view) {
        toolbarTitle.setText("个人中心");

    }


    /**
     * //懒加载--->再懒加载中加载数据
     * @param savedInstanceState
     */
    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        initData();
    }


    /**
     * 加载数据
     */
    private void initData() {


    }




    /**
     * 这个方法什么也没做
     * 只是这个页面注册了EventBus,相应的也应该有EventBus接受事件
     * @param eventcenter
     */
    @Subscribe
    public void onEvenThread(EventCenter eventcenter) {

    }





    /**
     * 退出应用
     */
    private void showQuitDialog() {
        LogUtils.e("显示", "推出");

        SPUtil.remove(Constant.KEY_USERNAME);
        SPUtil.remove(Constant.KEY_USERPWD);
        SPUtil.remove(Constant.KEY_IMEI);
//        PersistentCookieStore store = new PersistentCookieStore(_mActivity.getApplicationContext());
//        store.removeAll();
//        Intent intent = new Intent();
//        intent.setClass(getActivity(), LoginActivity.class);
//        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//        startActivity(intent);
        _mActivity.finish();

    }

    /**
     * 清除缓存
     */
    private void showClearDialog() {
        showAlertDialogNoMsg(getActivity(), "确定清除图片缓存？", "", new DialogClick() {
            @Override
            public void PositiveMessage() {
                GlideCacheUtil.getInstance().clearImageAllCache(getActivity());
                showShortToast(getActivity(), "清除成功");
               // imageCache.setText("0.0");
            }

            @Override
            public void NegativeMessage() {

            }
        });
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBus.getDefault().unregister(this);
        unbinder.unbind();
    }
}
